﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;

namespace DAO
{
    public class TrangThaiDao
    {
        public IEnumerable<TRANGTHAI> TrangThai()
        {
            DoixeDataContext DX = new DoixeDataContext();
            return DX.TRANGTHAIs;
        }
        public int LayMaTrangThai(string TenTrangThai)
        {
            DoixeDataContext DX = new DoixeDataContext();
            IEnumerable<TRANGTHAI> ttDto;
            ttDto = from tt in DX.TRANGTHAIs where tt.TenTrangThai == TenTrangThai select tt;
            if (ttDto.Count() == 0)
            {
                return -1;
            }
            return ttDto.Single().MaTrangThai;
        }
    }
}
